package school.repository;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class JdbcUtil {
	private static String url = "jdbc:db2://localhost:50001/DRSCHOOL:retrieveMessagesFromServerOnGetMessage=true;securityMechanism=4;";
	private static Connection connection;

	public static Connection connect() throws Exception {
		Properties props = new Properties();
		Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
		
		props.setProperty("user", "marta");
		props.setProperty("password", "samsung1");
		
		connection = DriverManager.getConnection(url, props);
		connection.setAutoCommit(false); // umożliwia transakcje

		return connection;
	}

	public static void disconnect() throws Exception {
		connection.commit();
		connection.close();
	}
}
